// xc_lshop/savemoney/com/swipernav.js
Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的属性列表
   */
  properties: {
    navarr: { // 导航数据
      type: Array,
      value: [],
      observer:function(newval,oldval){
        for(var i in newval){
          if(newval[i]['status']==-1)
          newval.splice(i,1)  
        }
        this.setData({
          navarr:newval
        })
      }
    },
  },
  
  /**
   * 组件的初始数据
   */
  data: {
    syswidth: 375,
    scrollleft: 0,
    dotnums: 0,

  },
  ready(){
  
    this.setData({
      scrollleft: 1,
      syswidth: wx.getSystemInfoSync().windowWidth
    })

    // var scrollWidth = this.data.syswidth
    //   var syswidth = this.data.syswidth
    //   var mod_val = scrollWidth % syswidth
    //   var dotnums = (scrollWidth - mod_val) / syswidth + (mod_val > 0 ? 1 : 0)

      
    //   this.setData({ scrollleft: 0, scrollWidth, dotnums })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    clicknav(e){
      var dataset = e.currentTarget.dataset;
      var item=dataset.item
   
      if(item.cid==1){
        wx.navigateTo({
          url:item.url,
        })
      }
    },
    initsiper(ev) {
      var scrollWidth = ev.detail.scrollWidth;
      var syswidth = this.data.syswidth
      var mod_val = scrollWidth % syswidth
      var dotnums = (scrollWidth - mod_val) / syswidth + (mod_val > 0 ? 1 : 0)     
      this.setData({ scrollleft: 0, scrollWidth, dotnums })
    },
  }
})
